<template>
	<view class="content">
		<view class="video-player">
			<video id="myVideo" :src="playSrc" @error="videoErrorCallback" controls></video>
		</view>

		<view class="video-intro">
			<uni-collapse ref="collapse">
				<uni-collapse-item class="video-name" :title="name">
					<view class="video-desc">
						{{desc}}
					</view>
				</uni-collapse-item>
			</uni-collapse>
		</view>


		<view class="video-detail">
			<view class="video-item" :class="{'active-item': currentIndex === index}" v-for="(item, index) in database"
				:key="index" @tap="handleSelectCourse(index)">
				{{item.level}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(props) {
			return {
				name: '外教带你看世界',
				desc: '简介内容简介内容简介内容简介内容简介内容',
				database: [{
						index: 1,
						level: '第01集',
						danmu: '',
						time: '2023.09.02 17:08',
					},
					{
						index: 2,
						level: '第02集',
						danmu: '',
						time: '2023.09.02 17:08',
					},
				],
				currentIndex: 0,
				playSrc: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4'
			}
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title: option.title,
			});
			this.renderData = this.database;
			this.renderType = option.type === 'video' ? 'raw' : 'column';
		},
		methods: {
			handleSelectCourse(index) {
				this.currentIndex = index;
			},
		}
	}
</script>

<style scoped>
	.content {
		padding: 0 32rpx;
	}

	.video-player {
		width: 686rpx;
		height: 400rpx;
		border-radius: 24rpx;
		overflow: hidden;
	}

	#myVideo {
		width: 686rpx;
		height: 400rpx;

	}

	.video-intro {
		width: 686rpx;
		box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(74, 144, 246, 0.06);
		margin: 24rpx auto;
		border-radius: 20px;
		position: relative;
	}

	.video-title {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 40rpx 28rpx 40rpx 40rpx;
		box-sizing: border-box;
	}

	.video-name {
		font-family: PingFangSC, PingFang SC;
		font-weight: 600;
		font-size: 32rpx;
		color: #222222;
		line-height: 44rpx;
		text-align: left;
		font-style: normal;
	}

	.video-desc {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #727A8E;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
		padding: 0 40rpx 32rpx;
	}

	.video-detail {
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(74, 144, 246, 0.06);
		border-radius: 24rpx;
		padding: 32rpx 32rpx 8rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.video-item {
		width: 298rpx;
		height: 104rpx;
		background: rgba(41, 121, 255, 0.05);
		border-radius: 12rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: rgba(34, 34, 34, 1);
		line-height: 104rpx;
		text-align: center;
		font-style: normal;
		margin-bottom: 24rpx;
	}

	.active-item {
		color: #FFFFFF;
		background: #2979FF;
	}
</style>